`ifndef TEST_SV
`define TEST_SV

`include "transaction.svh"

module automatic test;
	initial begin
		trans_a tr_base;
		trans_b trb, tr_ext;

		tr_base = new(1); // 创建基类trans_a对象
		if($cast(tr_ext, tr_base)) begin // 基类句柄指向基类对象，向下转换失败
			$display("casting success");
			tr_ext.print("casting");
		end
		else
			$display("casting fail");
		trb = new(1, 2); // 创建派生类trans_b对象
		tr_base = trb; // 基类句柄指向派生类对象
		if($cast(tr_ext, tr_base)) begin // 基类句柄指向派生类对象，向下转换成功
			$display("casting success");
			tr_ext.print("casting");
		end	
		else
			$display("casting fail");
	end
endmodule

`endif
